package com.lc.afbx.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONObject;

/**
 * Created by Administrator on 2016/6/12.
 */
@HttpInlet(Conn.INLET_API_MYORDER_CAR)
public class GetApiBusinessDetail extends BaseAsyGet<GetApiBusinessDetail.Info> {

    public String id, type;

    public GetApiBusinessDetail(AsyCallBack<GetApiBusinessDetail.Info> asyCallBack) {
        super(asyCallBack);
    }

    protected Info parser(JSONObject jsonObject) {

        TOAST = jsonObject.optString("message");
        if (jsonObject.optInt("code") == 200) {

            Info info = new Info();
            JSONObject o = jsonObject.optJSONObject("data");

            Data d = new Data();

            d.pstate = o.optString("pstate");
            d.ordersn = o.optString("ordersn");
            d.posttime = o.optString("posttime");
            d.total = o.optString("total");
            d.insurance_id = o.optString("insurance_id");
            d.stores_id = o.optString("stores_id");
            d.insurance = o.optString("insurance");
            d.store = o.optString("store");
            d.business_id = o.optString("business_id");
            d.tel = o.optString("tel");
            d.id_number = o.optString("id_number");
            d.insurance_name = o.optString("insurance_name");
            d.uid = o.optString("uid");
            d.username = o.optString("username");
            d.name = o.optString("name");

            JSONObject o1 = o.optJSONObject("insurant_info");

            if (o1!=null){

                InsurantInfo insurant = new InsurantInfo();
                insurant.address = o1.optString("address");
                insurant.id_number = o1.optString("id_number");
                insurant.name = o1.optString("name");
                insurant.tel = o1.optString("tel");

                d.insurant = insurant;
            }
            //TODO  这还没写
            info.data = d;

            return info;
        }
        return null;
    }


    public static class Info {
        public Data data;
    }

    public static class Data {

        //        "pstate": "1",
//                "ordersn": "20160528551005714",
//                "posttime": "2016-05-28 14:47:03",
//                "total": "5000.00",
//                "insurance_id": "3",
//                "stores_id": "2",
//                "insurant_info": {
//                      "name": "张三",
//                      "idnum": "230103199101014567",
//                      "tel": "13100112587",
//                      "address": "道里区西八道街2号"
//        }

        //        "insurance": "太平洋保险",
//                "store": "太平洋保险门店道理分店",
//                "insurance_name": "商业险"

//        "code": 200,
//                "message": "成功",
//                "data": {
//            "pstate": "1",
//                    "ordersn": "t201606281001024834",
//                    "posttime": "2016-06-28 18:25:49",
//                    "total": "3600.00",
//                    "insurance_id": "2",
//                    "business_id": "0",
//                    "tel": "13504855055",
//                    "id_number": "231181199111293933",
//                    "uid": "1",
//                    "username": "小明。",
//                    "store": null,
//                    "insurance_name": "交强险",
//                    "insurance": "人保车险"
//        }

        public String business_id, tel, id_number, uid, username, name;

        public String pstate, ordersn, posttime, total, insurance_id, stores_id, insurance, store, insurance_name;
        public InsurantInfo insurant;

    }

    public static class InsurantInfo {
        public String name, id_number, tel, address;
    }
}
